function [ vessel_trees ] = Modify_Tree( start_point,vessel_tree_num,vessel_trees )
%MODIFY_TREE Summary of this function goes here
%   Detailed explanation goes here
start_points=[];
start_points=[start_points;start_point];
segments=[];
i=vessel_tree_num;
while(1)
%element1
    for j=1:vessel_trees(i).element1.segments_num
        if isempty(start_points)==0
            if norm(vessel_trees(i).element1.segments(j).start(1,:)-start_points(1,:))==0
                temp_index=size(vessel_trees(i).element1.segments(j).end,1);
                start_points=[start_points;vessel_trees(i).element1.segments(j).end(temp_index,:)];
                segments=[segments,j];
            end
        end        
    end
    for k=1:length(segments)
        vessel_trees(i).element1.segments(segments(k))=[];
        vessel_trees(i).element1.segments_num=vessel_trees(i).element1.segments_num-1;
    end
    segments=[];
%element2      
    for j=1:vessel_trees(i).element2.segments_num
        if isempty(start_points)==0
            if norm(vessel_trees(i).element2.segments(j).start(1,:)-start_points(1,:))==0
                temp_index=size(vessel_trees(i).element2.segments(j).end,1);
                start_points=[start_points;vessel_trees(i).element2.segments(j).end(temp_index,:)];
                segments=[segments,j];
            end
        end        
    end
    for k=1:length(segments)
        vessel_trees(i).element2.segments(segments(k))=[];
        vessel_trees(i).element2.segments_num=vessel_trees(i).element2.segments_num-1;
    end
    segments=[];
%element3    
    for j=1:vessel_trees(i).element3.segments_num
        if isempty(start_points)==0
            if norm(vessel_trees(i).element3.segments(j).start(1,:)-start_points(1,:))==0
                temp_index=size(vessel_trees(i).element3.segments(j).end,1);
                start_points=[start_points;vessel_trees(i).element3.segments(j).end(temp_index,:)];
                segments=[segments,j];
            end
        end        
    end
    for k=1:length(segments)
        vessel_trees(i).element3.segments(segments(k))=[];
        vessel_trees(i).element3.segments_num=vessel_trees(i).element3.segments_num-1;
    end
    segments=[];
%element4    
    for j=1:vessel_trees(i).element4.segments_num
        if isempty(start_points)==0
            if norm(vessel_trees(i).element4.segments(j).start(1,:)-start_points(1,:))==0
                temp_index=size(vessel_trees(i).element4.segments(j).end,1);
                start_points=[start_points;vessel_trees(i).element4.segments(j).end(temp_index,:)];
                segments=[segments,j];
            end
        end        
    end
    for k=1:length(segments)
        vessel_trees(i).element4.segments(segments(k))=[];
        vessel_trees(i).element4.segments_num=vessel_trees(i).element4.segments_num-1;
    end
    segments=[];   
%element5   
    for j=1:vessel_trees(i).element5.segments_num
        if isempty(start_points)==0
            if norm(vessel_trees(i).element5.segments(j).start(1,:)-start_points(1,:))<1e-6
                temp_index=size(vessel_trees(i).element5.segments(j).end,1);
                start_points=[start_points;vessel_trees(i).element5.segments(j).end(temp_index,:)];
                segments=[segments,j];
            end
        end        
    end
    for k=1:length(segments)
        vessel_trees(i).element5.segments(segments(k))=[];
        vessel_trees(i).element5.segments_num=vessel_trees(i).element5.segments_num-1;
    end
    segments=[];
%element6 
    for j=1:0%vessel_trees(i).element6.segments_num
        if isempty(start_points)==0
            if norm(vessel_trees(i).element6.segments(j).start(1,:)-start_points(1,:))==0
                temp_index=size(vessel_trees(i).element6.segments(j).end,1);
                start_points=[start_points;vessel_trees(i).element6.segments(j).end(temp_index,:)];
                segments=[segments,j];
            end
        end        
    end
    for k=1:length(segments)
        vessel_trees(i).element6.segments(segments(k))=[];
        vessel_trees(i).element6.segments_num=vessel_trees(i).element6.segments_num-1;
    end
    segments=[];
     
    start_points(1,:)=[];
    if isempty(start_points)==1
        break;
    end
end
end

